package com.finger.forest.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.finger.forest.HotCheckActivity;
import com.finger.forest.HotListActivity;
import com.finger.forest.R;
import com.finger.forest.model.FzHotspot;

import java.util.List;

/**
 * 热点核查Adapter
 */
public class HotCheckListAdapter extends BaseQuickAdapter<FzHotspot, BaseViewHolder> {

    private Context context;
    private int type;

    public HotCheckListAdapter(int layoutResId, @Nullable List<FzHotspot> data, Context context, int type) {
        super(layoutResId, data);
        this.context = context;
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, FzHotspot item) {

        TextView hotName = (TextView) helper.getView(R.id.tv_hot_name);
        TextView hotCodeName = (TextView) helper.getView(R.id.tv_hot_code);
        TextView hotAddressName = (TextView) helper.getView(R.id.tv_hot_address);
        Button detailBtn = (Button) helper.getView(R.id.detailBtn);

        hotName.setText(item.gethCondition());
        hotCodeName.setText(item.gethHotspotNo());
        hotAddressName.setText(item.gethHotspotLoc());
        detailBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intentHotCheck = new Intent(context, HotCheckActivity.class);
                intentHotCheck.putExtra("hId", item.gethId());//热点ID
                intentHotCheck.putExtra("type", type);//反馈类型
                ((HotListActivity)context).startActivityForResult(intentHotCheck,1);
            }
        });


    }
}
